package com.icarus.quartz.detail;

import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import com.icarus.quartz.entity.QuartzJob;
import com.icarus.quartz.job.IQuartzJobBaseService;
import com.icarus.util.SpringUtil;

@DisallowConcurrentExecution
public class QuartzJobBaseDetail implements Job {

	@Override
	public void execute(JobExecutionContext context)
			throws JobExecutionException {
		QuartzJob jobInfo = (QuartzJob) context.getMergedJobDataMap()
				.get("jobInfo");
		String jobBeanName = jobInfo.getJobBeanName();
		IQuartzJobBaseService quartzjobBaseService = (IQuartzJobBaseService) SpringUtil
				.getBean(jobBeanName);
		try {
			quartzjobBaseService.execute(context);
		} catch (Exception e) {
			throw new JobExecutionException(e);
		}
	}

}
